package com.dx.as.listener;

import android.app.Activity;
import android.content.Context;

import com.dx.as.UI;
import com.dx.as.common.ILoadListener;

/**
 * Created by jwaoo on 2017/7/3.
 */

public abstract class IProInterface extends ILoadListener{
    private UI context;
    public IProInterface(Activity activity){
        this.context = (UI)activity;
    }
    public IProInterface(Activity activity,IViewInterface iViewInterface){
        this(activity);
    }

    //初始化相关数据数据
    public abstract void initialataData();

    public Context getContext(){
        return this.context.getApplicationContext();
    }

    public Activity getActivity(){
        return this.context;
    }

    @Override
    public void onResponse(Object response, int flg) {

    }

    @Override
    public void onFailure(int code, String errorMsg) {
        context.showSnackBar(errorMsg);
    }

    @Override
    public void onFailure(Throwable t) {
        context.showSnackBar(t.toString());
    }

    public void showSnackBar(String msg){
        context.showSnackBar(msg);
    }
}
